<?php
class test
{
    public static $game = "1";
    public $nogame = "2";

    public function __construct()
    {
        echo "get class";
    }
    public function Findme()
    {
        echo "找到我了吗？";
    }
}
interface game
{

}
class test_children extends test implements game
{

}
//逻辑代码  从 ReflectionClass  中分离方法
$prod_class = new ReflectionClass('test');
function methodData(ReflectionMethod $method)
{
    $details = "";
    $name = $method->getName();
    if ($method->isUserDefined()) {
        $details .= "$name is defind<br>";
    }
    if ($method->isInternal()) {
        $details .= "$name is Internal<br>";
    }
    if ($method->isAbstract()) {
        $detail .= "$name is Abstract method </br><br>";
  //抽象
    }

    if ($method->ispublic()) {
        $details .= "$name is public<br>";
    }


    if ($method->isProtected()) {
        $details .= "$name is Proected<br>";
    }

    if ($method->isPrivate()) {
        $details .= "$name is private<br>";
    }
    if ($method->isStatic()) {
        $details .= "$name is Static<br>";
    }
    if ($method->isFinal()) {
        $details .= "$name is Final<br>";
    }
    if ($method->isConstructor()) {
        $details .= "$name is  the Constructor<br>";
    }
    if ($method->returnsReference()) {
        $details .= "$name returns a refernce (as opposed to a value)<br>";
    }
    return $details;
}
$methods = $prod_class->getMethods();
foreach ($methods as $method) {
    print methodData($method);
    print "<br>";
    // var_dump($method["name"]);
    // var_dump( $method);
    echo "代码：" . ReflectionUtil::getMethodSource($method);
}
class ReflectionUtil
{
    static function getMethodSource(ReflectionMethod $method)
    {
        $path = $method->getFileName();
        $file = @file($path);
        $from = $method->getStartLine();
        $to = $method->getEndLine();
        $len = $to - $from + 1;
        return implode(array_slice($file, $from - 1, $len));
    }
}



